package com.fun.demo.crypt;

import org.bouncycastle.crypto.digests.SM3Digest;
import org.bouncycastle.util.encoders.Hex;

import java.util.Base64;

public class SM3Test {

    public static void main(String[] args) {
        String input = "Hello, SM3!";
//        byte[] hash = sm3Hash(input.getBytes());
//        System.out.println("SM3 Hash: " + Hex.toHexString(hash));
         byte [] data = input.getBytes();

         String sss = Base64.getEncoder().encodeToString(data);
        System.out.println( Base64.getEncoder().encodeToString(data));

        String sss2 = new String(Base64.getDecoder().decode(sss));
        System.out.println(sss2);


    }

    public static byte[] sm3Hash(byte[] data) {
        SM3Digest digest = new SM3Digest();
        digest.update(data, 0, data.length);
        byte[] hash = new byte[digest.getDigestSize()];
        digest.doFinal(hash, 0);
        return hash;
    }
}

